//
//  YTKAnimatingRequestAccessory.m
//  HaloBear
//
//  Created by monkey on 16/12/14.
//  Copyright © 2016年 刘～丹. All rights reserved.
//

#import "YTKAnimatingRequestAccessory.h"
//#import "HBAlertUtils.h"

@implementation YTKAnimatingRequestAccessory

-(id)initWithAnimatingView:(UIView *)animatingView animatingText:(NSString *)animatingText datasourceView:(UIView *)datasourceView
{
    self = [super init];
    if (self) {
        _animatingView = animatingView;
        _animatingText = animatingText;
        _datasourceView = datasourceView;
    }
    return self;
}

- (id)initWithAnimatingView:(UIView *)animatingView animatingText:(NSString *)animatingText {
    self = [super init];
    if (self) {
        _animatingView = animatingView;
        _animatingText = animatingText;
    }
    return self;
}

- (id)initWithAnimatingView:(UIView *)animatingView {
    self = [super init];
    if (self) {
        _animatingView = animatingView;
    }
    return self;
}

+ (id)accessoryWithAnimatingView:(UIView *)animatingView {
    return [[self alloc] initWithAnimatingView:animatingView];
}

+ (id)accessoryWithAnimatingView:(UIView *)animatingView animatingText:(NSString *)animatingText {
    return [[self alloc] initWithAnimatingView:animatingView animatingText:animatingText];
}

+(id)accessoryWithAnimatingView:(UIView *)animatingView animatingText:(NSString *)animatingText datasourceView:(UIView *)datasourceView
{
    return [[self alloc] initWithAnimatingView:animatingView animatingText:animatingText datasourceView:datasourceView];

}

- (void)requestWillStart:(id)request {
    if (_animatingView) {
        dispatch_async(dispatch_get_main_queue(), ^{
            // TODO: show loading
//            [HBAlertUtils hb_showLodingAlertView:_animatingText inView:_animatingView];
            _datasourceView.hidden = YES;
        });
    }
    NSLog(@"requestWillStart");

}

- (void)requestWillStop:(id)request {
    if (_animatingView) {
        dispatch_async(dispatch_get_main_queue(), ^{
            // TODO: hide loading
//            [HBAlertUtils hb_hideLoadingAlertView:_animatingView];
            _datasourceView.hidden = NO;

        });
    }
    NSLog(@"requestWillStop");

}

-(void)requestDidStop:(id)request
{
//    YTKBaseRequest *resultRequest = (YTKBaseRequest*)request;
//    NSError *error  =  resultRequest.error;
//    NSLog(@"%@",request);
    NSLog(@"requestDidStop");
}
@end
